<?php include "include/header.php" ?>
<div class="main-content">
					<div class="container">
										
						<div class="page-content">
						
							<!-- Heading -->
							<div class="single-head">
								<!-- Heading -->
								<h3 class="pull-left"><i class="fa fa-tags green"></i> Realtime Item</h3>
								<!-- Bread crumbs -->
								<div class="breads pull-right">
									<strong>Nav</strong> : <a href="<?=base_url('/')?>">Home</a> / <a href="<?=base_url('realtime_item')?>">Realtime Item</a>
								</div>
								<div class="clearfix"></div>
							</div>
							
							<!-- Posts page -->
							<div class="page-posts">
								<!-- Nav tabs -->
								<div class="page-tabs">
									<ul class="nav nav-tabs">
										<li class="active"><a href="#posts" class="br-lblue" data-toggle="tab"><i class="fa fa-tags lblue"></i> Realtime Item</a></li>
										<li><a href="#postnew" class="br-red" data-toggle="tab"><i class="fa fa-tag red"></i> Add Realtime Item</a></li>
									</ul>
									<!-- Tab panes -->
									<div class="tab-content">
										<div class="tab-pane fade active in" id="posts">
											
											<div class="clearfix"></div><br>
											<div class="table-responsive">
												<form id="item_form">
													<table class="table table-bordered">
														<thead>
															<tr>
																<th><input type='checkbox' onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});"/></th>
																<th>Item name</th>
																<th>Item key</th>
																<th>Item type</th>
																<th>Item server</th>
																<th>Safe value</th>
																<th>Alarm value</th>
																<th>Alarm content</th>
																<th>Edits</th>
															</tr>
														</thead>
														<tbody>														
															<?php foreach ($realtime_items as $row ) { ?>
																<tr>
																	<td class="ii"><input type='checkbox' name="item_id" value="<?=$row['item_id']?>" /></td>
																	
																	<td class="in"><?=$row['item_name']?></td>
																	<td class="ik"><?=$row['item_key']?></td>
																	<td class="it"><?=$row['item_type']?></td>
																	<td class="is"><?=$row['item_server']?></td>
																	<td class="sv"><?=$row['safe_value']?></td>
																	<td class="av"><?=$row['alarm_value']?></td>
																	<td class="ac"><?=$row['alarm_content']?></td>
																	<td>
																		<a data-toggle="modal" href="#realtime_item_update" class="btn btn-xs btn-danger report_item_edit"><i class="fa fa-pencil"></i></a>																		
																		<a class="btn btn-xs btn-success item_del" onclick="confirm('Are you sure to delete?',function(flag){if(flag){location.href='<?=base_url('realtime_item/delete')?>?item_id=<?=$row['item_id']?>'}})" href="javascript:;">
																		<i class="fa fa-trash-o"></i> </a>
																	</td>
																</tr>
															<?php } ?>
														</tbody>
													</table>
												</form>
											</div><!-- Table responsive end -->
										<!--
											<ul class="pagination pull-right">
												<li><a href="#">&laquo;</a></li>
												<li><a href="#">1</a></li>
												<li><a href="#">2</a></li>
												<li><a href="#">3</a></li>
												<li><a href="#">4</a></li>
												<li><a href="#">5</a></li>
												<li><a href="#">&raquo;</a></li>
											</ul>-->
											<div class="clearfix"></div>
										</div>
										<div class="tab-pane fade" id="postnew">
											<!-- Heading -->
											<h4>Add Realtime Item</h4>	
											<form class="form-horizontal" role="form"  method="post" action="<?=base_url('realtime_item/add')?>">
												
												<!-- Itemt Key area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Name</label>
													<div class="col-md-10">
														<input type="text" name="item_name" class="form-control" id="title" placeholder="Enter Item Name">
													</div>
												</div>
												<!-- Itemt name area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Key</label>
													<div class="col-md-10">
														<input type="text" name="item_key" class="form-control" id="title" placeholder="Enter Item Key">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Type</label>
													<div class="col-md-10">
														<input type="text" name="item_type" class="form-control" id="title" placeholder="Enter Item Type">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Server</label>
													<div class="col-md-10">
														<input type="text" name="item_server" class="form-control" id="title" placeholder="Enter Item Server">
													</div>
												</div>
												<!--sort area-->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Safe value</label>
													<div class="col-md-10">
														<input type="text" name="safe_value" class="form-control" id="title" placeholder="Enter Safe Value">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Alarm value</label>
													<div class="col-md-10">
														<input type="text" name="alarm_value" class="form-control" id="title" placeholder="Enter Alarm Value">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Alarm content</label>
													<div class="col-md-10">
														<input type="text" name="alarm_content" class="form-control" id="title" placeholder="Enter Alarm Content">
													</div>
												</div>
												<!-- Button -->
												<div class="form-group">
													<div class="col-md-offset-2 col-md-10">
													<div class="pull-right">
														<input type="submit" class="btn btn-default" value="Add" />
													</div>
													<div class="clearfix"></div>
													</div>
												</div>
											</form>
											
										</div>
									</div>
								</div>
							</div> <!-- Posts page end -->
							<!-- report update form -->
							<div class="modal fade" id="realtime_item_update" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
								<div class="modal-dialog">
								    <div class="modal-content">    
					 			        <div class="modal-header">
									        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
										        <h4 class="modal-title" id="exampleModalLabel">Update Realtime Item</h4>
										</div>
									    <div class="modal-body">
										    <form class="form-horizontal" role="form" method="post" action="<?=base_url('realtime_item/update')?>">
										    	<input type="checkbox" name="item_id" id="item_id" checked="checked" hidden>
										    	<!-- Itemt name area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Name</label>
													<div class="col-md-10">
														<input type="text" name="item_name" class="form-control" id="item_name" placeholder="Enter Item Name">
													</div>
												</div>
												<!-- Itemt Key area -->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Key</label>
													<div class="col-md-10">
														<input type="text" name="item_key" class="form-control" id="item_key" placeholder="Enter Item Key">
													</div>
												</div>
												
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Type</label>
													<div class="col-md-10">
														<input type="text" name="item_type" class="form-control" id="item_type" placeholder="Enter Item Type">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Item Server</label>
													<div class="col-md-10">
														<input type="text" name="item_server" class="form-control" id="item_server" placeholder="Enter Item Server">
													</div>
												</div>
												<!--sort area-->
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Safe value</label>
													<div class="col-md-10">
														<input type="text" name="safe_value" class="form-control" id="safe_value" placeholder="Enter Safe Value">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Alarm value</label>
													<div class="col-md-10">
														<input type="text" name="alarm_value" class="form-control" id="alarm_value" placeholder="Enter Alarm Value">
													</div>
												</div>
												<div class="form-group">
													<label for="tag" class="col-md-2 control-label">Alarm content</label>
													<div class="col-md-10">
														<input type="text" name="alarm_content" class="form-control" id="alarm_content" placeholder="Enter Alarm Content">
													</div>
												</div>
												<button type="submit" class="btn btn-info btn-block">Update</button>
										    </form>
										</div>
										<div class="clearfix"></div>
										<div class="modal-footer">
										    
									    </div>
								    </div>
						        </div>
							</div>
							<!-- report update form -->
						</div>
						
					</div>
				</div>
				</div>
			<!-- Mainbar ends -->
			
			<div class="clearfix"></div>
		</div>
<?php include "include/js.php" ?>
<script>
$(document).ready(function(){
	$("#realtime_item_update").on('show.bs.modal', function (event) {
		var button = $(event.relatedTarget);
		var item_id = button.parent().prevAll(".ii").children().val();
		var item_name = button.parent().prevAll(".in").text();
		var item_key = button.parent().prevAll(".ik").text();
		var item_type = button.parent().prevAll(".it").text();
		var item_server = button.parent().prevAll(".is").text();
		var safe_value = button.parent().prevAll(".sv").text();
		var alarm_value = button.parent().prevAll(".av").text();
		var alarm_content = button.parent().prevAll(".ac").text();
		var modal = $(this);
		modal.find('#item_id').val(item_id);
  		modal.find('#item_name').val(item_name);
  		modal.find('#item_key').val(item_key);
  		modal.find('#item_type').val(item_type);
  		modal.find('#item_server').val(item_server);   
  		modal.find('#safe_value').val(safe_value);
  		modal.find('#alarm_value').val(alarm_value);
  		modal.find('#alarm_content').val(alarm_content);
	});
	
});
</script>
<?php include "include/footer.php" ?>